package com.tanhua.controller;

import com.tanhua.domain.db.Admin;
import com.tanhua.domain.web.ResultInfo;
import com.tanhua.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping
@CrossOrigin
public class AdminController {

    @Autowired
    private AdminService adminService;

    /**
     * 登录功能
     */
    @RequestMapping("/user/login")
    public ResultInfo login(@RequestBody Admin admin) {
        //获取用户对象
        ResultInfo login = adminService.login(admin);
        return login;
    }

    /**
     * 用户退出
     */
    @RequestMapping("/user/logout")
    public void logout(String token) {
        adminService.logout(token);
    }


}
